<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>源辰-零食网登录</title>
<meta name="keywords" content="小吃,美食,零食,源辰" />
<meta name="description" content="各种小吃美食，应有尽有" />
<link href="images/yc.png" rel="shortcut icon" type="image/x-icon"/>
<link href="css/login.css" rel="stylesheet" type="text/css" />
<link href="css/footer.css" rel="stylesheet" type="text/css" />
<style>

</style>
</head>

<body>
<header>
	<a href="index.html" target="_blank"><img src="images/logo.png" alt="logo" title="点击进入零食网" /></a>
</header>

<article>
	<div class="loginarea" id="login">
    	<div class="item">
        	<h1>源辰会员 <a href="register.html">立即注册</a></h1>
        </div>
        
        <div class="item item-border">
        	<label for="account" class="login_label"></label>
            <input type="text" class="ipt" name="account" id="account" v-model="nickName" placeholder="邮箱/用户名/已验证的手机"/>
            <span class="clear_btn"></span>
        </div>
        
        <div class="item item-border">
        	<label for="pwd" class="login_label pwd_label"></label>
            <input type="password" maxlength="18" class="ipt" name="pwd" id="pwd" v-model="pwd" placeholder="密码"/>
            <span class="clear_btn"></span>
        </div>
        
         <div class="item item-border">
        	<label for="code" class="login_label pwd_label"></label>
            <input type="text" maxlength="4" class="ipt1" name="code" v-model="code" placeholder="验证码"/>
            <img class="code" src="code" onclick="this.src='code?' + Math.random()">
        </div>
        
        <div class="item item2">
        	<input type="checkbox" id="auto">
        	<label for="auto">自动登录</label>
          	<a href="#">忘记密码</a>
        </div>
        
        <div class="item">
          	<span style="color: red"></span>
          	<a href="javascript:void(0)" class="btn_img" @click="login">登录</a>
        </div>
        
        <div class="item item3">
          	<ul>
            	<li><a href="#"><span></span>QQ</a></li>
                <li><span></span></li>
                <li><a href="#"><span></span>微信</a></li>
            </ul>
        </div>
    </div>
</article>
<footer>
	<div class="foot_link">
        <a href="#">关于我们</a> <span> | </span>
        <a href="#">联系我们</a> <span> | </span>
        <a href="#">招聘广告</a> <span> | </span>
        <a href="#">友情链接</a>
    </div>
    <p>CopyRight &copy; 2019 <a class="copy" href="http://www.hyycinfo.com" target="_blank">衡阳市源辰信息科技有限公司</a> All Rights Reserverd</p>
    <p>电话：0734-8355998 湘ICP备16015987号-1</p>
</footer>
<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="js/vue.js"></script>
<script type="text/javascript" src="js/axios.js"></script>
<script type="text/javascript" src="js/show-dialog.js"></script>
<script type="text/javascript" src="js/qs.js"></script>
<script type="text/javascript">
let app = new Vue({
	el:"#login",
	data:{
		nickName:"",
		pwd:"",
		code:""
	},
	methods:{
		login: function(){
			console.log(this.code);
			if(!this.nickName || !this.pwd || !this.code){
				showmsg("你输入的登录信息不完全，请重新输入...", "yellow");
				return;
			}
			axios.post("menber/login", qs.stringify({nickName: this.nickName, pwd: this.pwd, code: this.code})).then( rt => {
				if(rt.status == 200 && rt.data.code == 200 ){
					let ref = document.referrer;
					if(ref == "" || ref.indexOf("register.html") > 0){
						location.href="index.html";
					}else {
						location.href=ref;

					}
					return;
				}else if(rt.data.code == 510 ){
					showmsg("验证码错误，请重新输入...", "red", function(){
						$("#code").attr('src', "code?" + Math.random());
					});
					return;
				}
				showmsg("账号或密码错误...", "red", function(){
					$("#code").attr('src', "code?" + Math.random());
				});
			});
		}
	}
});
</script>
</body>
</html>
